/**
* Dislcaimer :
* The Age Of Empire Project will have his name change due to some infrigment.
* You're free to use everything as you want, under GPLv2 terms.
* 
* Pre-Alpha content
* v0.1
*/


#include <iostream>

#include "../include/defines.h"
#include "../include/Batiment.h"
#include "../include/Caserne.h"
#include "../include/Entite.h"
#include "../include/Monde.h"
#include "../include/Position.h"
#include "../include/Carte.h"

// Graphique
#include "../include/MoteurGraphique.h"


using namespace std;

int main(){

	cout<<endl;
	cout<<" *********** AGE OF EMPIRE ******************"<<endl;
	cout<<"		preview 0.1			    "<<endl;
	cout<<" ********************************************"<<endl;
	cout<<endl;
	cout<<"Choisissez la résolution :"<<endl;
	cout<<"    0: 800x600"<<endl;
	cout<<"    1: 1024x768"<<endl;
	cout<<"    2: 1280x800"<<endl;
	cout<<"    3: 1600x900"<<endl;

	int choix;
	cin>>choix;
	if( choix < 0 || choix > 3 )
		return -1;

	// Creation d'un monde

	Taille t;
	t.x = 800;
	t.y = 600;
	Monde monde( t);

		// initialisation monde
		initPartie init;
		init.nbJoueurs = 2;
		init.type_config = 0; // debut par defaut
		init.ressources = new Ressource( 50, 50, 0);
		monde.initialiser( init);
		delete( init.ressources);


	MoteurGraphique m = MoteurGraphique(choix,monde);


	
	m.render();

	while( m.enCours() )
	{
		monde.executerUnTour();
		m.render( );
		m.tempo(10);
	}

	std::cout<<"clean exit"<<std::endl;


//	if( m.getChoix() != 0)
//		return 0;
	
	
	
	// test fichiers Monde
/*
	Monde m;
	initPartie init;
	init.nbJoueurs = 2;
	init.type_config = 0; // debut par defaut
	init.ressources = new Ressource( 50, 50, 0);
	m.initialiser( init);
	delete( init.ressources);
*/
	//text 3 : positions | p = position, t = taille
/*
	Carte c;

	Bloc b;
	b.p.x = 2;
	b.p.y = 2;

	b.t.x = 1;
	b.t.y = 1;

	Bloc a;
	a.p.x = 2;
	a.p.y = 2;

	a.t.x = 1;
	a.t.y = 1;

	std::cout<<c.collision(a, b)<<std::endl;
	
	a.p.x = 3;
	std::cout<<!c.collision(a, b)<<std::endl;

	b.t.x = 2;
	std::cout<<c.collision(a, b)<<std::endl;

	a.p.x = 4;
	std::cout<<!c.collision(a, b)<<std::endl;

	b.p.y = 3;
	std::cout<<!c.collision(a, b)<<std::endl;

	a.p.x = 3;
	a.p.y = 4;
	std::cout<<!c.collision(a, b)<<std::endl;

	b.t.y = 3;
	std::cout<<c.collision(a, b)<<std::endl;
*/
/*

	// test 2
	Ressource cout1(3,3,3);

	Ressource cout2(5,5,5);

	Ressource cout3 = cout2 - cout1;
	std::cout<<"Test cout :"<<cout2<<" - "<<cout1<<" = "<<cout3<<std::endl;

	 //test 1
	CarracteristiquesEntite c(1,10,1,4.0f, cout1);

	Guerrier david(0x00,&c),troll(0x01,&c);
	std::cout<<"PV david:"<<david.getPV()<<" | pv troll :"<<troll.getPV()<<std::endl;
    	while( troll.estVivant())
		david.taper( troll);

	troll.gagnerVie( 3);
   	std::cout<<"PV david:"<<david.getPV()<<" | pv troll :"<<troll.getPV()<<std::endl;

	// test 3
	Caserne caserne(0x00,&c);
	caserne.produireUnite( GUERRIER,&c);
	c.setTpsConstruction(1.0f);
	caserne.produireUnite( GUERRIER, &c);
	c.setTpsConstruction(2.0f);
	caserne.produireUnite( GUERRIER, &c);
	Entite *e = NULL;
	while( e == NULL )
	{
		e= caserne.produire();
	}
	cout<<"Unite produite !"<<std::endl;
	e = NULL;
	while( e == NULL )
	{
		e= caserne.produire();
	}
	e = NULL;
	cout<<"Unite produite !"<<std::endl;
	while( e == NULL )
	{
		e= caserne.produire();
	}
	cout<<"Unite produite !"<<std::endl;

	//Villageois superDavid( 0x00,&c);
	std::cout<<"construction :"<<std::endl;
	std::cout<<caserne.getVieMax()<<std::endl;
	while( !caserne.estConstruit()  ){
		std::cout<<caserne.getPourcentageConstruction()<<std::endl;
		caserne.construire( 1);
	}
	std::cout<<"construction ok"<<std::endl;*/
    return 0;
}
